﻿/*
copyright 2005@crl e_mail:zzmmcrl@163.com;
*/
import mx.events.EventDispatcher;
class com.Mxml extends XML {
	public var ignoreWhite = true;
	private var mtitle:Array;
	private var murl:Array;
	private var mp3Movie:String;
	public var addEventListener:Function;
	public var removeEventListener:Function;
	private var dispatchEvent:Function;
	private var xmlInterval:Number;
	private var httpStatus:Number;
	public var httpStatusType:String = "xml is no find";
	//private var 
	//加载设置;
	private static var _dispacher = EventDispatcher.initialize(com.Mxml.prototype);
	public function Mxml() {
		mtitle = new Array();
		murl = new Array();
	}
	public function loading() {
		xmlInterval = setInterval(this, "Progress", 100);
	}
	private function Progress() {
		var loaded = this.getBytesLoaded();
		var total = this.getBytesTotal();
		//trace(loaded+":"+total);
	}
	private function onLoad():Void {
		var _this = this;
		clearInterval(xmlInterval);
		if (_this.hasChildNodes()) {
			var array:Array = this.firstChild.childNodes;
			_this.mp3Movie = this.firstChild.attributes["mp3Movie"].toString();
			var Length = array.length;
			for (var i = 0; i<Length; i++) {
				murl.push(array[i].childNodes[1].firstChild.toString());
				mtitle.push(array[i].childNodes[0].firstChild.toString());
			}
			this.dispatchEvent({type:"init", target:this});
		} else {
			this.dispatchEvent({type:"error", target:this});
		}
	}
	//end onLoad;
	function onHTTPStatus(httpStatus:Number) {
		var _this = this;
		this.httpStatus = httpStatus;
		if (httpStatus<100) {
			this.httpStatusType = "crl prompt You  ::Sorry It's flashError";
		} else if (httpStatus<200) {
			this.httpStatusType = "crl prompt You  ::Sorry It's informational";
		} else if (httpStatus<300) {
			this.httpStatusType = "crl prompt You  ::Sorry It's successful";
		} else if (httpStatus<400) {
			this.httpStatusType = "crl prompt You  ::Sorry It's redirection";
		} else if (httpStatus<500) {
			this.httpStatusType = "crl prompt You  ::Sorry It's clientError";
		} else if (httpStatus<600) {
			this.httpStatusType = "crl prompt You  ::Sorry It's serverError";
		}
		dispatchEvent({type:"error", target:_this});
	}
	public function getLen():Number {
		return murl.length;
	}
	public function Title(i:Number):String {
		return mtitle[i];
	}
	public function Url(i:Number):String {
		return murl[i];
	}
	public function getMMovie() {
		return mp3Movie;
	}
}
//end class;
